package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.pojo.ShiftPhase;
import com.example.mapper.ShiftPhaseMapper;
import com.example.service.IShiftPhaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 班次阶段表 服务实现类
 * </p>
 *
 * @author wsl
 * @since 2022-04-14
 */
@Service
public class ShiftPhaseServiceImpl extends ServiceImpl<ShiftPhaseMapper, ShiftPhase> implements IShiftPhaseService {

    @Autowired
    private ShiftPhaseMapper spm;

    @Override
    public Boolean uptZero(Integer[] integers) {
        for (Integer i : integers) {
            ShiftPhase phase = new ShiftPhase();
            phase.setEnabled(0);
            QueryWrapper<ShiftPhase> wrapper = new QueryWrapper<>();
            wrapper.eq("shift_id",i);
            spm.update(phase,wrapper);
        }
        return true;
    }

    @Override
    public Boolean uptOne(Integer[] integers) {
        for (Integer i : integers) {
            ShiftPhase phase = new ShiftPhase();
            phase.setEnabled(1);
            QueryWrapper<ShiftPhase> wrapper = new QueryWrapper<>();
            wrapper.eq("shift_id",i);
            spm.update(phase,wrapper);
        }
        return true;
    }

    @Override
    public Boolean delAll(Integer[] integers) {
        for (Integer i : integers) {
            QueryWrapper<ShiftPhase> wrapper = new QueryWrapper<>();
            wrapper.eq("shift_id",i);
            spm.delete(wrapper);
        }
        return true;
    }
}
